var pageii = null;
var grid = null;
if(interval!=null){
	clearInterval(interval);//取消定时器
}
$(function() {	
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id"
		},{
			colkey : "Machine_ID",
			name : "机台号"
		},{
			colkey : "Machine_model",
			name : "机器型号"
		},{
			colkey : "Mold_Number",
			name : "模具编号"
		}, {
			colkey : "Material_Type",
			name : "原料型号"
		},{
			colkey : "Materials_Brand",
			name : "用料品牌"
		},{
			colkey : "Clients",
			name : "客户"
		},{
			colkey : "Enactment_Date",
			name : "制定日期",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		},{
			colkey : "status",
			name : "状态"
			
		},{
			colkey : "operation",
			name : "操作", 
			
		}],
		jsonUrl : rootPath + '/process/testmold_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});

	$("#assessment").click("click", function() {
		assessment();
	});
	$("#details").click("click", function() {
		DetalisAccount();
	});
	$("#delFun").click("click", function() {
		delAccount();
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#testMo").click("click", function() {
		testMoAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});

function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "修改工艺",
		type : 2,
		area : [ "1200px", "100%" ],
		content : rootPath + '/process/testmold_edit.shtml?id=' + cbox+'&status=1'
	});
}
function DetalisAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1) {
		layer.msg("只能选中一个");
		return;
	}
	if(cbox == ""){
		layer.msg("需要选择一个");
		return;
	}
	pageii = layer.open({
		title : "查看工艺",
		type : 2,
		area : [ "1000px", "100%" ],
		content : rootPath + '/process/testmold_edit.shtml?id=' + cbox+'&status=2'
	});
	
}
function delAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择删除项！！");
		return;
	}
	layer.confirm('是否删除？', function(index) {
		var url = rootPath + '/process/testmold_deleteEntity.shtml';
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if (s == "success") {
			layer.msg('删除成功');
			grid.loadData();
		} else {
			layer.msg('删除失败');
		}
	});
}


function testMoAccount() {
	layer.confirm('是否试模？', function(index) {
		pageii = layer.open({
			title : "试模模式",
			type : 2,
			area : [ "1200px", "100%" ],
			content : rootPath + '/process/machine.shtml'
		});
	});
}
function assessment() {
	layer.confirm('是否编写评估？', function(index) {
		pageii = layer.open({
			title : "编写评估",
			type : 2,
			area : [ "1200px", "100%" ],
			content : rootPath + '/process/assessmentMachine_Entity.shtml'
		});
	});
}